The instructions for an active application in a computer system are generally loaded into system memory before they are executed. A computer system's performance is generally improved if there is more system memory available for the execution of active applications. Indeed, an application requiring real-time processing of complex calculations such as voice-recognition software, interactive graphics, etc., will not run properly at all unless a certain amount of RAM (Random Access Memory) is reserved for its use.
High-speed system memory is a limited resource and, as with most limited resources, there is often competition for it. This has become an even greater problem in modern multi-tasked systems in which several applications may be running, or at least resident in memory, at the same time. More efficient management of RAM can reduce the cost, energy, or physical space required to support a given workload. Alternatively, more efficient management of RAM can allow a system to support a larger number of applications with better performance, given a fixed monetary, energy, or physical space budget.
An application may be defined broadly as any body of code that is loaded and that executes substantially as a unit. Applications include, among countless other examples, common consumer programs such as word processors, spreadsheets and games; Internet browsers and e-mail programs; software drivers; web servers; and software implementations of a whole computer, commonly known as a “virtual machine” (VM).
One technique for reducing the amount of system memory required for a given workload, and thereby for effectively “expanding” the amount of available system memory, is a scheme in which different applications share the same memory space. With transparent page sharing, in the context of a computer system on which virtual machines are running, memory is conserved by eliminating redundant copies of memory pages, such as those that contain program code, file system buffer cache, or any other replicated code or data. This is especially advantageous for reducing memory overhead associated with running multiple copies of operating systems, e.g., multiple Guest operating systems running in different virtual machines.
U.S. Pat. No. 6,789,156 to Waldspurger for “Content-Based, Transparent Sharing of Memory Units,” (hereafter “Waldspurger '156 patent” or “the '156 patent,”) the entire contents of which is hereby incorporated by reference for all purposes, implements content-based identification of units of a data storage space that different contexts, e.g., different virtual machines, may be able to share. In the '156 patent, the demand on the system memory can be reduced by allowing one or more contexts to share a single copy of a page of memory when possible, but creating private copies of the page when necessary. Sharing may take place either intra-context or inter-context, or both. The '156 patent describes various ways to determine when two pages of memory are identical and could be shared between contexts.
The Waldspurger '156 patent leverages the write-protection features of a memory system to mark or identify one or more pages, either individually or as a group, in such a way that any attempt to write to those pages will be detected and, therefore, the writing or changing can be prevented or at least delayed.
The term “context” is used here to refer to any software or hardware component, device or system, that addresses and reads from the hardware memory and that has its own address translation (mapping) state. For a traditional OS, a “context” would typically be a “process,” which has an address space and associated page tables that contain information about how to map virtual pages to physical pages, and also page-level protection information, such as “read-only” for copy-on-write (COW) pages.
Sharing of pages can often lead to improved performance, for example, the likelihood of contention for memory is reduced because more memory becomes freed for other uses. As above, sharing may allow the use of less memory, leading to the need for fewer or smaller memory devices which, in turn, reduces design complexity and can result in lower energy use, and may save physical space on circuit boards. Such savings are highly desirable, especially in small, mobile systems.
While there are known systems for identifying opportunities for sharing memory, there are still issues as to being able to share memory for as long as possible, even in situations where it may appear that the sharing of memory between two or more contexts should be terminated.